/***2024-12-14 迷途小羔羊
* 用于编写SkillCfg配置
*/
namespace ghost
{
    export class SkillCfg
    {   
        /**给角色添加默认技能*/
		public static addDefaultSkill(r:GameRole, skillId:number=1):void
		{
			let skillCfg:SkillCfg;
			skillCfg = SkillConfig.getSkill(skillId);
			r.addSkillData(
				{
					skillId:skillId,
					skillCfg:skillCfg,                                    
					cd:skillCfg.cd,
					// preCD:skillCfg.preCd
				}
			);
            r.skillDataChange();
		}
        public dataSet(tableLine:Object_skill):void
        {
            let skill:Object_skill;
            let s= this;
            skill = tableLine;
            
            s.skillId = skill.id;
            s.skillName= skill.name;
            // s.preCd=skill.preCd;
            s.priority=skill.priority;
            // s.skillTarget=[];
            s.condition=skill.condition < PeakType.MIN_DISTANCE || skill.condition > PeakType.MIN_PROTECTED?skill.condition:PeakType.MIN_DISTANCE;
            s.skillRange=skill.skillRange;
            // s.activeSkill=skill.activeSkill?skill.activeSkill:1;
            // if(skill.skillNub && skill.skillNub.length > 0)
            //     s.skillNub=[GYLite.Express.analyze(skill.skillNub[0]),GYLite.Express.analyze(skill.skillNub[1]),GYLite.Express.analyze(skill.skillNub[2]),skill.skillNub[3]?Number(skill.skillNub[3]):0];
            s.skillNub = skill.skillNub;
            s.type=skill.type;
            s.action=skill.action;
            // s.actionTime=(skill.actionTime|0)/1000;
            // s.warnSkill=skill.warnSkill;
            s.cd=skill.cd;
            s.buff = skill.buff;
            // s.cdPro=skill.cdPro;
            // s.icon=skill.icon;
            // s.buff=skill.buff;
            s.num=skill.skillNum?skill.skillNum:1;
            // s.attackSound= skill.attackSound;
            // s.hitSound= skill.hitSound;

            // let i:number,len:number;
            // let buffGroup:number;
            // //公共权重处理
            // s.buffWeight = [];
            // s.randBuff = [];
            // if(skill.randBuff && skill.randBuff.length > 0)
            // {
            //     len = skill.randBuff.length;				
            //     for(i=0;i<len;i+=4)
            //     {					
            //         buffGroup = skill.randBuff[3]|0;
            //         if(s.buffWeight[buffGroup] == null)
            //         {
            //             s.buffWeight[buffGroup] = 0;
            //             s.randBuff[buffGroup] = [];
            //         }
            //         s.randBuff[buffGroup].push(skill.randBuff[i],skill.randBuff[i + 1],skill.randBuff[i + 2]);
            //         s.buffWeight[buffGroup] += skill.randBuff[0];
            //     }
            // }   

            s.campFlag = 1+2+4;
            s.skillTarget = skill.skillTarget;
            // if(skill.skillTarget && skill.skillTarget.length > 0)
            // {
            //     len = skill.skillTarget.length;
            //     for(i=0;i<len;i+=2)	
            //     {
            //         s.skillTarget[s.skillTarget.length] = [skill.skillTarget[i],skill.skillTarget[i+1]];
            //         if(skill.skillTarget[i] == 1)
            //             s.campFlag += 1;
            //         else if(skill.skillTarget[i] == 2)
            //             s.campFlag += 2;
            //         else if(skill.skillTarget[i] == 3)
            //             s.campFlag += 4;
            //     }		
            // }
            // if(skill.skillNub && skill.skillNub.length > 0)
            // {
            //     len = skill.skillNub.length;
            //     for(i=0;i<len;i+=2)
            //         s.skillNub[s.skillNub.length] = [skill.skillNub[i],skill.skillNub[i+1]];
            // }
            // if(skill.skillEnhancement && skill.skillEnhancement.length > 0)
            // {
            //     len = skill.skillEnhancement.length;
            //     for(i=0;i<len;i+=2)
            //         s.enhanceSkills[skill.skillEnhancement[i]] = skill.skillEnhancement[i + 1] / 1000;
            //     s.enhanceSkills.length = len / 2|0;
            // }
            
            if (skill.hitEffect && skill.hitEffect.length > 0) {
                s.hitEffect = Conf.createEffectObj(skill.hitEffect,0,EffectType.SINGLE);
            }
            if (skill.attackEffect && skill.attackEffect.length > 0) {
                s.attackEffect = Conf.createEffectObj(skill.attackEffect,0,EffectType.ATTACK);
            }
        }
        /**技能id*/skillId:number;
        /**技能名称*/skillName:string;       
        /**技能优先级越小越优先，必须大于0*/priority:number;
        /**单次技能期间可以允许击中的不同目标的数量*/skillTarget:number;
        /**技能针对的阵营方*/campFlag:number;
        /**选择目标的条件*/condition:number;
        /**出手距离*/skillRange:number;
        // activeSkill:number;
        /**技能伤害*/skillNub:number;
        /**技能类型*/type:number;
        /**动作*/action:number;
        /**动作速率*/actionTime?:number;
        // warnSkill:number;
        /**cd*/cd:number;
        /**受击特效*/hitEffect:EffectArray;
        /**攻击特效*/attackEffect:EffectArray;
        // cdPro:number;
        // icon:string;
        buff:number[][];
        // randBuff:number[][];
        // buffWeight:number[];
        num:number;
        // attackSound:string;
        // hitSound: string;
        
    }
}